package com.zliuyno.io.testreactor.netty;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class SerDerUtil {

    static ByteArrayOutputStream out =  new ByteArrayOutputStream();

    public synchronized static byte[] ser(Object msg){
        out.reset();
        byte[] msgBody = null;
        ObjectOutputStream objOut= null;
        try {
            objOut = new ObjectOutputStream(out);
            objOut.writeObject(msg);
            msgBody = out.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return msgBody;
    }

}
